package com.up.stores.interceptor;

import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class AdminInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        if (!request.getSession().getAttribute("Type").equals("Admin")) {
            response.sendRedirect("/web/user/login.html");
            response.sendRedirect("/web/Order1/change_status.html");
            response.sendRedirect("/web/Order1/approval.html");
            response.sendRedirect("/web/Order1/Receiver.html");
            response.sendRedirect("/web/address.html");
            return false;
        }
        return true;
    }
}
